#ifndef TASK_CLIENT_FACTORY_H
#define TASK_CLIENT_FACTORY_H

#include <QObject>
#include "src/task_action_client.h"
#include "include/ros_worker.h"

// 任务客户端工厂类
class TaskClientFactory : public QObject {
    Q_OBJECT
public:
    explicit TaskClientFactory(ROSWorker* worker, QObject* parent = nullptr) 
        : QObject(parent), worker_(worker) {}
    
    Q_INVOKABLE QObject* createTaskClient(const QString& namespaceName) {
        // 创建TaskClientNode实例
        TaskClientNode* client = new TaskClientNode(namespaceName.toStdString());
        
        // 将新创建的客户端添加到ROS执行器中
        worker_->addTaskClientNode(client);
        
        return client;
    }

private:
    ROSWorker* worker_;
};

#endif // TASK_CLIENT_FACTORY_H